#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <unordered_map>

class Cpp_Next {
public:
    using Function = std::function<void(const std::vector<std::string>&)>;

    void defineFunction(const std::string& name, Function func) {
        functions_[name] = func;
    }

    void run(const std::string& code) {
        auto tokens = tokenize(code);
        if (tokens.empty()) return;

        if (tokens[0] == "print" && tokens.size() > 1) {
            functions_["print"](std::vector<std::string>(tokens.begin() + 1, tokens.end()));
        }
    }

private:
    std::vector<std::string> tokenize(const std::string& code) {
        std::vector<std::string> tokens;
        std::string token;
        for (char ch : code) {
            if (isspace(ch)) {
                if (!token.empty()) {
                    tokens.push_back(token);
                    token.clear();
                }
            } else {
                token += ch;
            }
        }
        if (!token.empty()) tokens.push_back(token);
        return tokens;
    }

    std::unordered_map<std::string, Function> functions_;
};

int main() {
    Cpp_Next script;

    // 定义 print 函数
    script.defineFunction("print", [](const std::vector<std::string>& args) {
        for (const auto& arg : args) {
            std::cout << arg << ' ';
        }
        std::cout << '\n';
    });

    // 运行 Cpp_Next 代码
    script.run("print Hello, World!");

    return 0;
}

